﻿using System;
using System.Collections.Generic;
using System.Text;
using NLBS.Entity;
using NLBS.Data;
using NLBS.Data.Business;

namespace NLBS.Syndication
{
   public class CommentRssWriter:BaseRssWriter<Comment>
    {
       public CommentRssWriter(IList<Comment> entries, DateTime dateLastViewedFeedItemPublished, bool useDeltaEncoding)
            : base(dateLastViewedFeedItemPublished, useDeltaEncoding)
        {
            this.Items = entries;
            this.UseAggBugs = true;
        }

        protected override string GetCategoriesFromItem(Comment item)
        {
            return string.Empty;
        }

        protected override string GetTitleFromItem(Comment item)
        {
            return "Comment on:"+ArticleData.GetArticleByID(item.LogID).Title;
        }

        protected override string GetLinkFromItem(Comment item)
        {
            string url = string.Format("article.aspx?id={0}#comment{1}", item.LogID.ToString(), item.CommentID.ToString());
            return blogInfo.BaseUrl +url;
        }

        protected override string GetBodyFromItem(Comment item)
        {
            return item.Content;
        }

        protected override string GetAuthorFromItem(Comment item)
        {
            return item.Author;
        }

        protected override DateTime GetPublishedDateUtc(Comment item)
        {
            return item.PostTime;
        }

        protected override bool ItemCouldContainComments(Comment item)
        {
            return false;
        }

        protected override bool ItemAllowsComments(Comment item)
        {
            return false;
        }

        protected override bool CommentsClosedOnItem(Comment item)
        {
            return false;
        }

        protected override int GetFeedbackCount(Comment item)
        {
            return 1;
        }

        protected override DateTime GetSyndicationDate(Comment item)
        {
            return DateTime.Now;
        }

        protected override string GetCommentRssLink(Comment item)
        {
            return string.Empty;
        }

        protected override bool IsComment
        {
            get
            {
               return true;
            }
        }
    }
}
